package charset;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class CharSetDemo {

    public static void main(String[] args) {
        try {
            String str = "\uD83D\uDC4C";
            // 获取字符串的UTF-8编码字符串（16进制）

            String strUtf8 = URLEncoder.encode(new String(str.toString().getBytes("UTF-8")),"UTF-8");
            System.out.println(strUtf8);

            // 打印Unicode字库序号的二进制
            for(char c : str.toCharArray()){
                System.out.print(Integer.toBinaryString(c));
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }
}
